package com.bsoft.controller.JSON;


import com.bsoft.service.ThirdLevelPubHosPerformanceAssessService;
import com.bsoft.utils.JSONUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/*三级公立医院绩效考核  ThirdLevelPubHosPerformanceAssess*/

@Controller
@RequestMapping(value = "JSON/ThirdLevelPubHosPerformanceAssess")
public class ThirdLevelPubHosPerformanceAssessController {
    private static Logger logger = LoggerFactory.getLogger(ThirdLevelPubHosPerformanceAssessController.class);

    @Autowired
    private ThirdLevelPubHosPerformanceAssessService thirdPubHosService;

    @RequestMapping(value = "queryOrderData", produces = "application/json;charset=utf-8", method = RequestMethod.POST)
    @ResponseBody
    public String queryOrderData(@RequestBody Map<String, Object> req) throws Exception {
        logger.info("三级公立医院绩效考核:入参:" + JSONUtil.map2Json(req));

        String dicType = req.get("dicType").toString();
        String res = "";
        if ("1".equals(dicType)) {
            res = hosInpatientOrderUplod(req);
        } else {
            res = hosOutpatientOrderUplod(req);
        }
        logger.info("三级公立医院绩效考核:出参:" + res);
        return res;
    }

    /**
     * 医院住院医嘱数据上传 hosInpatientOrderUplod
     */
    @RequestMapping(value = "hosInpatientOrderUplod", produces = "application/json;charset=utf-8", method = RequestMethod.POST)
    @ResponseBody
    public String hosInpatientOrderUplod(@RequestBody Map<String, Object> req) throws Exception {
        logger.info("三级公立医院绩效考核:医院住院医嘱数据上传:入参:" + JSONUtil.map2Json(req));
        String res = thirdPubHosService.hosInpatientOrderUplod(req);
        logger.info("三级公立医院绩效考核:医院住院医嘱数据上传:出参:" + res);
        return res;
    }

    @RequestMapping(value = "hosOutpatientOrderUplod", produces = "application/json;charset=utf-8", method = RequestMethod.POST)
    @ResponseBody
    public String hosOutpatientOrderUplod(@RequestBody Map<String, Object> req) throws Exception {
        logger.info("三级公立医院绩效考核:医院门诊医嘱数据上传:入参:" + JSONUtil.map2Json(req));
        String res = thirdPubHosService.hosOutpatientOrderUplod(req);
        logger.info("三级公立医院绩效考核:医院门诊医嘱数据上传:出参:" + res);
        return res;
    }

    @RequestMapping(value = "thirdLevelPubHosDicUplod", produces = "application/json;charset=utf-8", method = RequestMethod.POST)
    @ResponseBody
    public String thirdLevelPubHosDicUplod(@RequestBody Map<String, Object> req) throws Exception {
        logger.info("三级公立医院绩效考核:字典[{}:type:{}]数据上传:入参:{}", req.get("dicName"), req.get("dicType"), JSONUtil.map2Json(req));
        String res = thirdPubHosService.thirdLevelPubHosDicUplod(req);
        logger.info("三级公立医院绩效考核:医院给药途径字典数据上传:出参:" + res);
        return res;
    }


}
